use Graph::ModularDecomposition qw(pairstring_to_graph tree_to_string);

my $graphstring = <>;
my $g = new Graph::ModularDecomposition;
my $h = $g->pairstring_to_graph($graphstring);

# my $h = $g->pairstring_to_graph( 'ab,ac,ad,ae,cd,cf,cg,ch,dc,df,dg,dh,ef,eg,eh,fb,fe,gb,gf,ge,gh,hb,he' );
#print "yes\n" if check_transitive( $h );
#print "yes\n" if $h->check_transitive; # same thing
my $m = $h->modular_decomposition_EGMS;

print $ARGV[0]."\n";
print tree_to_string( $m ) . "\n";

# primitive[gabd|ceh|f]
#	(
# X	linear[gh|f]([g];complete_0[hf]([h];[f]));
# U	[a];
# Y	[b];
# Z	complete_1[cd]([c];[d]);
# W	[e]
#	)


#a-b,a-c,a-d,a-e,c-f,c-g,c-h,d-f,d-g,d-h,e-f,e-g,e-h,f-b,f-e,g-b,g-e,g-f,g-h,h-b,h-e,c-d,d-c,
#10-1,10-2,10-3,10-4,2-5,2-6,2-7,3-5,3-6,3-7,4-5,4-6,4-7,5-1,5-4,6-1,6-4,6-5,6-7,7-1,7-4,2-3,3-2,

# my $g = new Graph::ModularDecomposition;

# my $h = $g->pairstring_to_graph( 'nodea-nodeb,nodea-nodec,nodea-noded,nodeb-nodec,nodeb-noded' );
# #print "yes\n" if check_transitive( $h );
# #print "yes\n" if $h->check_transitive; # same thing
# my $m = $h->modular_decomposition_EGMS;
# print tree_to_string( $m );